<template>
  <div>
    <MyHeader title="购物车案例"></MyHeader>
    <div class="main">
      <MyGoods v-for="(item, index) in list"
               :key="item.id"
               :i="index"
               :gObj="item"></MyGoods>
    </div>
    <MyFooter :arr="list"></MyFooter>
  </div>
</template>

<script>
import MyHeader from "./components/MyHeader";
import MyGoods from "./components/MyGoods";
import MyFooter from "./components/MyFooter";
import { mapState, mapActions } from "vuex";
export default {
  components: {
    MyHeader,
    MyGoods,
    MyFooter,
  },
  created () {
    this.setNewList()
  },
  computed: {
    ...mapState('cart', ['list']),
  },
  methods: {
    ...mapActions('cart', ['setNewList'])
  },
};
</script>

<style scoped>
.main {
  padding-top: 45px;
  padding-bottom: 50px;
}
</style>